package org.example.day;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/25 21:47
 */
public class Solution189 {

    public static void main(String[] args) {
        Solution189 solution = new Solution189();
        int[] nums = new int[]{1,2,3,4,5,6,7};
        solution.rotate(nums, 0);
        for (int num : nums) {
            System.out.println(num);
        }
    }

    public void rotate(int[] nums, int k) {
        k = k%nums.length;
        if(k == 0){
            return;
        }
        int[] res = new int[nums.length];

        for (int i = 0; i < res.length; i++) {
            if( i < k){
                res[i] = nums[nums.length - k + i];
            }else {
                res[i] = nums[i - k];
            }
        }
        for (int i = 0; i < nums.length; i++) {
            nums[i] = res[i];
        }
    }

}
